import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
import layout from "./components/layout.vue";
//import router from "./utils/router/index";

const routes: RouteRecordRaw[] = [
  {
    path: "/",
    component: layout,
    redirect: "/home",
    children: [
      {
        path: "/home",
        component: () => import("/@/views/home/index.vue"),
      },
      {
        path: "/category",
        component: () => import("/@/views/category/index.vue"),
      },
      {
        path: "/find",
        component: () => import("/@/views/find/index.vue"),
      },
      {
        path: "/cart",
        component: () => import("/@/views/cart/index.vue"),
      },
      {
        path: "/my",
        component: () => import("/@/views/my/index.vue"),
      }
    ],
  }
];

const Router = createRouter({
  history: createWebHistory(),
  routes,
});

// 跳转后返回顶部
Router.afterEach(() => {
  //window.scrollTo(0,0);
})

export default Router;
